package litpag;

/**
 *掌握常见字面量的书写格式
 *
 */

public class Literal {
    public static void main(String[] args) {
        // 整数字面量
        System.out.println("整数字面量：");
        int a = 123;
        int b = 0123;
        int c = 0x7f;
        int d = 0b1111;
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);

        System.out.println("=========================");

        // 浮点数字面量
        System.out.println("浮点数字面量：");
        float f1 = 3.14f;
        double f2= 3.14;
        System.out.println(f1);
        System.out.println(f2);

        System.out.println("=========================");

        // 字符字面量
        System.out.println("字符字面量：");
        char ch = 'A';
        System.out.println(ch);
        char ch2 = '\u0041';
        System.out.println(ch2);
        char ch3 = '\n';
        System.out.println(ch3);
        char ch4 = '\\';
        System.out.println(ch4);
        char ch6 = '\"';
        System.out.println(ch6);
        char ch7 = '\u4e2d';
        System.out.println(ch7);
        char ch8 = '中';
        System.out.println(ch8);

        System.out.println("=========================");

        // 布尔字面量
        System.out.println("布尔字面量：");
        boolean flag = true;
        System.out.println(flag);
        boolean flag2 = false;
        System.out.println(flag2);

        System.out.println("=========================");

        // 字符串字面量
        System.out.println("字符串字面量：");
        String str = "Hello,World!";
        System.out.println(str);
        String str2 = "\"Hello,World!\"";
        System.out.println(str2);
        String str3 = "\"\"";
        System.out.println(str3);
        String str4 = "\"\\\"\"";
        System.out.println(str4);
        String str5 = "\"\\\\\"";
        System.out.println(str5);

        System.out.println("=========================");


        // 空字符
        System.out.println("空字符：");
        char chNull = '\0';
        System.out.println(chNull);
        char chNull2 = 0;
        System.out.println(chNull2);
        char chNull3 = '\u0000';
        System.out.println(chNull3);
        char chNull4 = 0x0000;
        System.out.println(chNull4);
        char chNull5 = 0b0000;
        System.out.println(chNull5);

        System.out.println("=========================");

        // 空字符串
        System.out.println("空字符串：");
        String strNull = "";
        System.out.println(strNull);
        String strNull2 = "\"\"";
        System.out.println(strNull2);
        String strNull3 = "''";
        System.out.println(strNull3);
        String strNull4 = "\"\\\"\"";
        System.out.println(strNull4);

        System.out.println("=========================");

        // 空指针
        System.out.println("空指针：");
        Object obj = null;
        System.out.println(obj);

        System.out.println("=========================");

    }
}
